<template>
	<view>
		<view class="wallet-list" v-for="(item,index) in month" :key="index">
			<view class="top">
				<view class="title">{{item.name}}</view>
				<view class="right">
					<view class="mintitle" v-if="item.transfer==1"
						@click="onDetali(`/pageA/wallet/transfer?id=${item.id}&name=${item.name}`)">{{$t('wallet.name9')}}</view>
					<view class="mintitle" v-if="item.recharge==1"
						@click="onDetali(`/pageA/wallet/onchargecost?id=${item.id}&name=${item.name}&code=${item.code}`)">
						{{$t('wallet.name3')}}</view>
					<view class="mintitle" v-if="item.withdrawal==1"
						@click="onDetali( `/pageA/wallet/withdrawal?id=${item.id}&name=${item.name}`)">{{$t('wallet.name1')}}</view>
					<view class="mintitle" v-if="item.code=='hold'"
						@click="onDetali( `/pageC/investment/investment?id=${item.id}&name=${item.name}`)">{{$t('wallet.name5')}}</view>
					<!-- <view class="mintitle" v-if="item.code=='recover'||item.code=='intergral'"
						@click="onDetali( `/pageC/resetvalue/resetvalue?id=${item.id}&code=${item.code}&name=${item.name}&fire_exchange_recover=${item.fire_exchange_recover}`)">
						兑换</view> -->
					<view class="mintitle" v-if="item.code=='intergral'" @click="btnshow(item)">
						{{$t('wallet.name4')}}</view>
				</view>
			</view>
			<view class="bottom">
				<view class="num">{{item.money}}</view>
				<view class="more"
					@click="onDetali(`/pageA/wallet/walletdetail?id=${item.id}&name=${item.name}&code=${item.code}`)">{{$t('wallet.name2')}}
				</view>
			</view>
		</view>
		<u-overlay :opacity="0.3" :show="addshow1">
			<view class="showpaw">
				<view class="text">{{$t('wallet.name4')}}</view>
				<u-input :placeholder="$t('wallet.name6')+$t('wallet.name7')" border="surround" v-model="mobile" fontSize='14'
					class="textinput"></u-input>
				<u-input :placeholder="$t('wallet.name6')+$t('wallet.name8')" border="surround" v-model="pointmoney" fontSize='14'
					class="textinput"></u-input>
				<view class="btn flex_between">
					<view class="btn_close" @click="addshow1=false">{{$t('cancel')}}</view>
					<view class="btn_sure" @click="psure">{{$t('confirm')}}</view>
				</view>
			</view>
		</u-overlay>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				month: {
					money: '--',
					balance: '--',
					charges: '--',
					point: '--',
					score: '--',
					shopping: '--',
				},
				addshow1: false,
				mobile: '',
				pointmoney: ''
			}
		},
		onShow() {
			this.init()
		},
		methods: {
			// 初始化
			init() {
				this.getList()
			},
			btnshow(item) {
				this.addshow1 = true
				this.codeid = item.id
			},
			psure() {
				if (this.mobile == '') {
					this.$fun.msg(this.$t('wallet.name6')+this.$t('wallet.name7'))
					return;
				}
				if (this.pointmoney == '') {
					this.$fun.msg(this.$t('wallet.name6')+this.$t('wallet.name8'))
					return;
				}
				this.$fun.ajax.post('user/exchangeIntergral', {
					money: this.pointmoney,
					mobile: this.mobile,
				}).then(res => {
					if (res.code == 1) {
						this.$fun.msg(res.msg);
					}
					this.addshow1 = false
				})
			},
			// 获取数据
			getList() {
				this.$fun.ajax.post('user/balance', {}).then(res => {
					this.month = res.data
				})
			},
			// 查看详情
			onDetali(url) {
				this.$fun.jump(url)
			},
		}
	}
</script>

<style lang="scss">
	page {
		background: #f7f7f9;
	}

	.flex_between {
		display: flex;
		justify-content: space-between;
	}

	.wallet-list {
		margin: 30rpx auto;
		background: #fff;
		border-radius: 10upx;
		padding: 50upx 30rpx;
		box-sizing: border-box;
		width: 690rpx;
		height: 184rpx;
		background: #FFFFFF;
		border-radius: 24rpx;

		.top {
			display: flex;
			justify-content: space-between;

			.title {
				font-weight: 500;
				font-size: 28rpx;
				color: #333333;
			}

			.right {
				display: flex;

				.mintitle {
					font-weight: 500;
					font-size: 24rpx;
					color: #FFFFFF;
					// width: 100rpx;
					padding: 0 20rpx;
					height: 48rpx;
					background: #5990FF;
					border-radius: 32rpx;
					text-align: center;
					line-height: 48rpx;
					margin-left: 30rpx;

					&:nth-child(1) {
						margin-left: 0;
					}
				}
			}
		}

		.bottom {
			display: flex;
			justify-content: space-between;
			margin-top: 10upx;

			.num {
				font-weight: 500;
				font-size: 36rpx;
				color: #5990FF;
			}

			.more {
				font-weight: 500;
				font-size: 24rpx;
				color: #5990FF;
				width: 100rpx;
				height: 48rpx;
				border-radius: 32rpx;
				border: 2rpx solid #5990FF;
				line-height: 48rpx;
				text-align: center;
			}
		}
	}

	.showpaw {
		width: 560rpx;
		// height: 224rpx;
		background: #FFFFFF;
		border-radius: 24rpx;
		padding: 40rpx 30rpx;
		box-sizing: border-box;
		position: fixed;
		top: 30%;
		left: 95rpx;
		right: 95rpx;

		.textinput {
			margin-bottom: 20rpx;
		}

		.text {
			font-weight: 500;
			font-size: 30rpx;
			color: #333333;
			text-align: center;
			margin-bottom: 30rpx;
		}

		.btn {
			margin-top: 40rpx;

			&_close {
				width: 230rpx;
				height: 64rpx;
				border-radius: 32rpx;
				border: 2rpx solid #4D88FF;
				font-weight: 500;
				font-size: 26rpx;
				color: #4D88FF;
				line-height: 64rpx;
				text-align: center;
			}

			&_sure {
				width: 230rpx;
				height: 64rpx;
				border-radius: 32rpx;
				background: #4D88FF;
				font-weight: 500;
				font-size: 26rpx;
				color: #FFFFFF;
				line-height: 64rpx;
				text-align: center;
			}
		}
	}

	.addshow {
		height: 320rpx;
	}
</style>